<%@page import="helpers.UrlHelper"%>
<%@page import="entities.OwnerDomain"%>
<%@page import="entities.SiteConfig"%>
<%@page import="java.util.TreeMap"%>
<%
	TreeMap check = (TreeMap) request.getAttribute("check");
	String success = (String) request.getAttribute("success");
	SiteConfig siteConfig = (SiteConfig) request.getAttribute("config");
	String image = UrlHelper.getServerUrl(request) + "/blobstore-serve?blob-key=" + siteConfig.getLogo();
	String form = (String) request.getAttribute("form");
	OwnerDomain ownerDomain = (OwnerDomain) request.getAttribute("ownerDomain");
%>


<jsp:include page="/demo/layouts/header.jsp">
    <jsp:param name="title" value="<%=siteConfig.getTitle()%>" />
    <jsp:param name="description" value="<%=siteConfig.getMetaDescription()%>" />
    <jsp:param name="keywords" value="<%=siteConfig.getMetaKeywords()%>" />
    <jsp:param name="ogsite_name" value="<%=siteConfig.getSiteName()%>" />
    <jsp:param name="ogtitle" value="<%=siteConfig.getTitle()%>" />
    <jsp:param name="ogurl" value="<%=UrlHelper.getServerUrl(request)%>" />
    <jsp:param name="ogimage" value="<%=image %>" />
    <jsp:param name="ogdescription" value="<%=siteConfig.getMetaDescription()%>" />
</jsp:include>

		<div class="dir">
			<a href="/home">Home</a> >  Verify
		</div>
		<br />
		<div class="submit-form">
			<form action="" method="post">
			<table width="100%" cellpadding="0" cellspacing="0">
				<thead>
					<tr>
						<td><div class="title-form">Verify your domain <%=ownerDomain.getDomain() %></div></td>
					</tr>
				</thead>
				<tbody>
					<tr>
						<td>
							<p>We treat your privacy seriously. Only owners and authorized webmasters can change sites. Verification is required to avoid unauthorized access and modifications.
Please complete the process using one of 2 easy methods below:</p>
						</td>
					</tr>
					<tr>
						<td>
							<% if (check.get("verifyMethod") != null) { %>
							<div class="verify-error">
								<%=check.get("verifyMethod") %>
							</div>
							<% } %>
							<% if (check.get("verifyUrl") != null) { %>
								<%=check.get("verifyUrl") %>
							<div class="verify-error">
								<img width="16" height="16" align="top" style="margin-right: 3px;" src="/i/d.png">
								Verification of <strong><%=ownerDomain.getDomain()%></strong> failed. Please read details below and try again.
								<br>
								<div style="margin: 27px;"><strong>Reason:</strong><br>
							            
							        We can not open or verify content of
							        <a target="_blank" href="http://<%=ownerDomain.getDomain()%>/<%=ownerDomain.getCodeVerify()%>.txt">http://<%=ownerDomain.getDomain()%>/<%=ownerDomain.getCodeVerify()%>.txt</a><br>
							        This means it was not found or does not contain verification code: <%=ownerDomain.getCodeVerify()%><br>
							        Please check file verification instructions below and re-upload it again.    
								</div> 
							</div>
							<% } %>
							<% if (check.get("verifyCode") != null) { %>
							<div class="verify-error">
								<%=check.get("verifyCode") %>
								<img width="16" height="16" align="top" style="margin-right: 3px;" src="/i/d.png">
								Verification of <strong><%=ownerDomain.getDomain()%></strong> failed. Please read details below and try again.
								<br>
								
								<div style="margin: 27px;"><strong>Reason:</strong><br>
							            <%=UrlHelper.getServerUrl(request) %> verification Meta tag was not detected. Please follow instructions below to add it to your home page or consider using file verification method instead.	
								</div> 
							</div>
							<% } %>
						</td>
					</tr>
					<tr>
						<td><div class="title-form">Verification Method</div></td>
					</tr>
					<tr>
						<td>
							<select name="verifyMethod">
								<option value="url" <%=ownerDomain.getVerifyMethod().equalsIgnoreCase("url") ? "selected=\"selected\"" : "" %>>Upload file</option>
								<option value="code" <%=ownerDomain.getVerifyMethod().equalsIgnoreCase("code") ? "selected=\"selected\"" : "" %>>Insert html code</option>
							</select>
							
							<!-- blockurl -->
							<div id="blockurl">
		    					<ul>
		    						<li>1. Download this HTML verification file <strong><a href="/static/file?txt=<%=ownerDomain.getCodeVerify()%>"><%=ownerDomain.getCodeVerify()%>.txt</a></strong>.</li>
		  							<li>2. Upload the file to <a href="http://<%=ownerDomain.getDomain()%>"><%=ownerDomain.getDomain()%></a></li>
		                            <li>3. Confirm successful upload by visiting <a target="_blank" href="http://<%=ownerDomain.getDomain()%>/<%=ownerDomain.getCodeVerify()%>.txt">http://<%=ownerDomain.getDomain()%>/<%=ownerDomain.getCodeVerify()%>.txt</a></li>
		                            <li>4. Click Verify below. <br> To keep your verified status please do not remove the file after verification.</li>    
								</ul>
		    				</div>
		    				
		    				<!-- blockcode -->
		    				<div id="blockcode">
                                Add a meta tag to your home page HTML (If you are able to edit your home page)<br>
                                 Instructions:<br>
    				    		<ul>
                                	<li> Copy the meta tag below, and paste it into your site's home page. 
                                            It should go in the &lt;head&gt; section, before the first &lt;body&gt; section.<br>
                                            <span style="border: 1px dotted black;">&lt;meta name="<%=UrlHelper.getServerUrl(request) %>/validation" content="<%=ownerDomain.getCodeVerify() %>" /&gt;</span><br><br>
                                            Example:<br>
                                            <div style="margin-left: 10px; color: #0072BC;">
                                                &lt;html&gt;<br>
                                                &lt;head&gt;<br>
                                                <span style="color: green">&lt;meta name="<%=UrlHelper.getServerUrl(request) %>/validation" content="<%=ownerDomain.getCodeVerify() %>" /&gt;</span><br>
                                                &lt;title&gt; My title &lt;/title&gt;<br>
                                                &lt;/head&gt;<br>
                                                &lt;body&gt;<br>
                                                page contents<br>
                                                &lt;/body&gt;<br>
                                                &lt;/html&gt;<br>
                                            </div>
                                	</li>
                                	<li>2. Click Verify below. To keep your verified status please do not remove the meta tag after verification.</li>							
								</ul>
    						</div>
						</td>
					</tr>
					<tr>
						<td>
							<button type="submit">Verify</button>
						</td>
					</tr>
				</tbody>
			</table>
			</form>
		</div>
<script type="text/javascript" src="/demo/js/verify_domain.js"></script>
<jsp:include page="/demo/layouts/footer.jsp">
    <jsp:param name="language" value="1" />
</jsp:include>